import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// 数据目录路径
export const dataDir = path.join(__dirname, '..', 'data');

// 数据文件路径
export const dataFiles = {
  users: path.join(dataDir, 'users.json'),
  students: path.join(dataDir, 'students.json'),
  teachers: path.join(dataDir, 'teachers.json'),
  marketingDepartment: path.join(dataDir, 'marketingDepartment.json'),
  classes: path.join(dataDir, 'classes.json'),
  counselors: path.join(dataDir, 'counselors.json'),
  colleges: path.join(dataDir, 'colleges.json'),
  dormitories: path.join(dataDir, 'dormitories.json'),
  dormBuildings: path.join(dataDir, 'dormBuildings.json'),
  grades: path.join(dataDir, 'grades.json'),
  classGrades: path.join(dataDir, 'classGrades.json'),
  studentComments: path.join(dataDir, 'studentComments.json'),
  courses: path.join(dataDir, 'courses.json'),
  attendance: path.join(dataDir, 'attendance.json'),
  roles: path.join(dataDir, 'roles.json'),
  permissions: path.join(dataDir, 'permissions.json'),
  rolePermissions: path.join(dataDir, 'rolePermissions.json'),
  userRoles: path.join(dataDir, 'userRoles.json')
};

// JWT配置
export const jwtConfig = {
  secret: 'your-jwt-secret-key',
  expiresIn: '24h'
};

// Spug推送配置
export const spugConfig = {
  apiUrl: 'https://push.spug.cc/send/peJ9bm35Dqr6QDNy',
  accessToken: '52751ab7cc7d42b081f6215deecffd47'
};

// 确保数据目录存在
if (!fs.existsSync(dataDir)) {
  fs.mkdirSync(dataDir, { recursive: true });
  console.log('创建数据目录:', dataDir);
}